﻿// CheckModelPropertyGridCtrl.cpp: 实现文件
//

#include "stdafx.h"
#include "zChecker.h"
#include "CheckModelPropertyGridCtrl.h"


// CCheckModelPropertyGridCtrl

IMPLEMENT_DYNAMIC(CCheckModelPropertyGridCtrl, CMFCPropertyGridCtrl)

CCheckModelPropertyGridCtrl::CCheckModelPropertyGridCtrl()
{
	m_pModel = NULL;
}

CCheckModelPropertyGridCtrl::~CCheckModelPropertyGridCtrl()
{
	if (m_pModel != NULL)
	{
		m_pModel->Release();
		m_pModel = NULL;
	}
}


BEGIN_MESSAGE_MAP(CCheckModelPropertyGridCtrl, CMFCPropertyGridCtrl)
	ON_WM_CREATE()
END_MESSAGE_MAP()



// CCheckModelPropertyGridCtrl 消息处理程序




int CCheckModelPropertyGridCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CMFCPropertyGridCtrl::OnCreate(lpCreateStruct) == -1)
		return -1;

	// TODO:  在此添加您专用的创建代码

	return 0;
}

void CCheckModelPropertyGridCtrl::Populate(ck::CheckModel* pModel)
{
	if (m_pModel != NULL)
	{
		m_pModel->Release();
		m_pModel = NULL;
	}

	this->RemoveAll();
	m_pModel = pModel;
	if (m_pModel)
	{
		m_pModel->AddRef();

		CMFCPropertyGridProperty* pGroup = new CMFCPropertyGridProperty(_T("模型信息"));
		
		z_uint32 id = pModel->GetID();
		z_uint32 code = pModel->GetCode();
		const char* szCode = pModel->GetSCode();
		const char* szName = pModel->GetName();
		const char* szProduct = pModel->GetProduct();
		const char* szDescription = pModel->GetDescription();
		
		pGroup->AddSubItem(new CMFCPropertyGridProperty("模型名称", (_variant_t)szName, _T("")));
		pGroup->AddSubItem(new CMFCPropertyGridProperty("模型编码", (_variant_t)szCode, _T("")));
		pGroup->AddSubItem(new CMFCPropertyGridProperty("数据产品", (_variant_t)szProduct, _T("")));
		pGroup->AddSubItem(new CMFCPropertyGridProperty("模型说明", (_variant_t)szDescription, _T("")));
		

		this->AddProperty(pGroup);
	}
}